Skip to content

[WIP] On demand analyze for allocation - #37

Draft
keremsahn wants to merge 2 commits into
compiler-research:mainfrom
keremsahn:on-demand-analyze
Draft

[WIP] On demand analyze for allocation#37
keremsahn wants to merge 2 commits into
compiler-research:mainfrom
keremsahn:on-demand-analyze

Conversation

@keremsahn

@keremsahn keremsahn commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Built upon #35
Added wrapping for GetAllocType, and it is called if user sets gUseAllocAnalyze variable, which is disabled by default. Analyzer has lower priority compared to attribute check.

A detail: Analyzer caches the result, so once the function is called with gUseAllocAnalyze, the result stays, even though the flag is set to False laterly.
@aaronj0 @vgvassilev @Vipul-Cariappa

@keremsahn
keremsahn force-pushed the on-demand-analyze branch 2 times, most recently from 7a6eddc to 29f069b Compare August 22, 2026 17:22
@Vipul-Cariappa
Vipul-Cariappa marked this pull request as draft August 23, 2026 04:54
@Vipul-Cariappa Vipul-Cariappa changed the title On demand analyze for allocation [WIP] On demand analyze for allocation Aug 23, 2026

@Vipul-Cariappa Vipul-Cariappa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. LGTM!

Comment thread test/test_memoryanalysis.py Outdated
def test03_analyzer_new(self):
import cppjit

cppjit._backend.SetUseAllocAnalyzer(True)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a wrapper in __init__.py, such that the user can directly do
cppjit.use_alloc_analyzer(...). Note that in Python, function names should be in snake case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the wrapper, it is cppjit.use_alloc_analyzer()

Comment thread test/test_memoryanalysis.py Outdated
Comment on lines +44 to +47
cppjit._backend.SetUseAllocAnalyzer(False)
obj = cppjit.gbl.allocNew2()
assert type(obj) == cppjit.gbl.memAnalysisKlass
assert not (obj.__python_owns__)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test for reusing existing results... i.e. already analyzed, but use_alloc_analyzer(False).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment thread test/cpp/memory_analysis.h Outdated
Comment on lines +13 to +14
inline memAnalysisKlass* allocNew() { return new memAnalysisKlass; }
inline memAnalysisKlass* allocNew2() { return new memAnalysisKlass; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the function names be a bit more descriptive? In the context of the test. Example:
AnalysisOnAllocNew & AnalysisOffAllocNew?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

…p information and this information effects kIsCreator flag of overload group , currently analyzer is not called, just attribute checker is called
@keremsahn
keremsahn force-pushed the on-demand-analyze branch 3 times, most recently from 6185725 to 4e3a996 Compare August 30, 2026 18:10
…mory-related attributes in the FunctionDecl, analyzer is disabled by default and set by cppjit.use_alloc_analyzer(True/False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants